/*
 * @lc app=leetcode.cn id=258 lang=rust
 *
 * [258] 各位相加
 */

// @lc code=start
impl Solution {
    pub fn add_digits(num: i32) -> i32 {
        let mut num = num as i32;

        while num > 9 {
            let mut ret = 0 as i32;
            while num != 0{
                ret += num % 10;
                num /= 10;
            }
            num = ret;
        }

        return num;
    }
}
// @lc code=end

